﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraBars;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraBars.Helpers;
using Manager;
using Manager.FormMain;
using Manager.FormAdd_Edit;
using Manager.App_Code.REPORTS;
using System.Runtime.InteropServices;
using Manager.App_Code.DTO;
using Manager.App_Code;
using System.Linq;
using Manager.Common;


namespace Manager
{
    public partial class Form1 : RibbonForm
    {
        public NewPearl_HotelDataContext db = null;
        public NguoiDung user;
        Frm_Ribbon_DanhMuc frmDanhMuc = new Frm_Ribbon_DanhMuc();
        Frm_Ribbon_TienSanh frmTienSanh = new Frm_Ribbon_TienSanh();
        Frm_RoomDiagram xfrmbrbt5 = new Frm_RoomDiagram();

        #region function private
        #     region Chuyển Đổi Giờ Hệ Thống
        [System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "GetUserDefaultLCID", ExactSpelling = true)]
        private static extern int API_iGetUserDefaultLCID();

        [DllImport("kernel32.dll", EntryPoint = "GetLocaleInfoA", SetLastError = true)]
        public extern static long API_lGetLocaleInfo(long lLocale, long lLocaleType, [Out]System.Text.StringBuilder lpLCData, long lBufferLength);

        [DllImport("kernel32.dll", EntryPoint = "SetLocaleInfoA", SetLastError = true)]
        public extern static bool API_bSetLocaleInfo(int iLocale, int iLCType, string strLCData);

        [DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)]
        public extern static long API_lPostMessage(long hWnd, long wMsg, long wParam, long lParam);

        private const int LOCALE_SYSTEM_DEFAULT = 0x400;
        private const int LOCALE_SDECIMAL = 0xE;
        private const int LOCALE_STHOUSAND = 0xF;
        private const int LOCALE_SMONDECIMALSEP = 0x16;
        private const int LOCALE_SMONTHOUSANDSEP = 0x17;
        private const int LOCALE_SSHORTDATE = 0x1F;
        private const int LOCALE_SLONGDATE = 0x20;

        private const int WM_SETTINGCHANGE = 0x1A;
        private const int HWND_BROADCAST = 0xFFFF;

        public static void ChuyenDoi()
        {
            try
            {
                int dwLCID;
                string strDecimalPointChar = ",";
                string strThousandPointChar = ".";
                string strShortDate = "MM/dd/yyyy";
                System.Text.StringBuilder lpLCData = new System.Text.StringBuilder(256);

                dwLCID = API_iGetUserDefaultLCID();

                if (API_bSetLocaleInfo(dwLCID, LOCALE_SSHORTDATE, strShortDate) == false)
                    return;

                if (API_bSetLocaleInfo(dwLCID, LOCALE_SDECIMAL, strDecimalPointChar) == false)
                    return;

                if (API_bSetLocaleInfo(dwLCID, LOCALE_STHOUSAND, strThousandPointChar) == false)
                    return;

                if (API_bSetLocaleInfo(dwLCID, LOCALE_SMONDECIMALSEP, strDecimalPointChar) == false)
                    return;

                if (API_bSetLocaleInfo(dwLCID, LOCALE_SMONTHOUSANDSEP, strThousandPointChar) == false)
                    return;

                API_lPostMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }

        #endregion
  
        /// <summary>
        /// Tạo thêm tab mới
        /// </summary>
        /// <param name="tabControl">Tên TabControl để add thêm tabpage mới vào</param>
        /// <param name="Text">Tiêu đề tabpage mới</param>
        /// <param name="Name">Tên tabpage mới</param>
        /// <param name="form">Tên form con của tab mới</param>
        /// <param name="imageIndex">index của icon</param>
        void TabCreating(DevExpress.XtraTab.XtraTabControl tabControl, string Text, string Name, DevExpress.XtraEditors.XtraForm form, int imageIndex)
        {
            int index = KiemTraTonTai(tabControl, Name);
            if (index >= 0)
            {
                tabControl.SelectedTabPage = tabControl.TabPages[index];
                tabControl.SelectedTabPage.Text = Text;
            }
            else
            {
                DevExpress.XtraTab.XtraTabPage tabpage = new DevExpress.XtraTab.XtraTabPage { Text = Text, Name = Name, ImageIndex = imageIndex };
                tabControl.TabPages.Add(tabpage);
                tabControl.SelectedTabPage = tabpage;

                form.TopLevel = false;
                form.Parent = tabpage;
                form.Show();
                form.Dock = DockStyle.Fill;
            }
        }

        /// <summary>
        /// Kiểm tra tabpage có tồn tại hay không.
        /// </summary>
        /// <param name="tabControlName">Tên tabControl để kiểm tra.</param>
        /// <param name="tabName">Tên tabpage cần kiểm tra.</param>
        /// <returns></returns>
        static int KiemTraTonTai(DevExpress.XtraTab.XtraTabControl tabControlName, string tabName)
        {
            int re = -1;
            for (int i = 0; i < tabControlName.TabPages.Count; i++)
            {
                if (tabControlName.TabPages[i].Name == tabName)
                {
                    re = i;
                    break;
                }
            }
            return re;
        }
        #endregion        

        public Form1()
        {
            InitializeComponent();
            InitSkinGallery();
        }

        public Form1(NguoiDung _user)
        {
            InitializeComponent();
            InitSkinGallery();
            //change test
            siInfo.Caption = _user.HoTen;
            user = _user;
            Variables.NguoiDung = _user;
        }

        private void Form1_Load(object sender, EventArgs e)
        {            
            db = new NewPearl_HotelDataContext();            
            if (user != null)
            {
                if (user.MaNhom == "1")
                {
                    RoleAdmin();
                }
                else
                {
                    RoleNhanVien();
                }
            }

            ChuyenDoi();
            
            TabCreating(tabMain, rbPageTienSanh.Text, rbPageTienSanh.Text, frmTienSanh, rbPageTienSanh.ImageIndex);            
            TabCreating(frmTienSanh.tabControl, "Danh sách phòng", "DSPhong", xfrmbrbt5, 8);            
            
            //TabCreating(xTab_BtmTabCtrl, homeRibbonPage.Name, homeRibbonPage.Name, xfrmrbp1, homeRibbonPage.ImageIndex);

            //Frm_RoomDiagram xfrmbrbt6 = new Frm_RoomDiagram();
            //TabCreating(xfrmrbp1.xtraTabControl1, "Danh sách phòng", "DSPhong", xfrmbrbt6, 8);
        }

        void InitSkinGallery()
        {
            SkinHelper.InitSkinGallery(rgbiSkins, true);
        }

        public void RoleAdmin()
        {
            rbPageQuanTriHeThong.Visible = true;
            rbPageDanhMuc.Visible = true;
        }

        public void RoleNhanVien()
        {
            rbPageQuanTriHeThong.Visible = false;
            rbPageDanhMuc.Visible = false;
        }

        public void RestoreDefault()
        {

        }

        private void iExit_ItemClick(object sender, ItemClickEventArgs e)
        {
            Application.Exit();            
        }

        private void ribbonControl_SelectedPageChanged(object sender, EventArgs e)
        {
            //if (ribbonControl.SelectedPage == homeRibbonPage)
            //    TabCreating(xTab_BtmTabCtrl, homeRibbonPage.Name, homeRibbonPage.Name, xfrmrbp1, homeRibbonPage.ImageIndex);
            //if (ribbonControl.SelectedPage == helpRibbonPage)
            //    TabCreating(xTab_BtmTabCtrl, helpRibbonPage.Name, helpRibbonPage.Name, xfrmrbp2, helpRibbonPage.ImageIndex);
     
        }

        private void tabMain_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e)
        {
            if (tabMain.SelectedTabPage.Name == rbPageDanhMuc.Name)
                ribbonControl.SelectedPage = rbPageDanhMuc;
            if (tabMain.SelectedTabPage.Name == rbPageTienSanh.Name)
                ribbonControl.SelectedPage = rbPageTienSanh;
        }

        private void iHelp_ItemClick(object sender, ItemClickEventArgs e)
        {
            //xfrmrbp1.xtraTabControl1.Images = imageCollection16x16;

            //TabCreating(xTab_BtmTabCtrl, helpRibbonPage.Name, helpRibbonPage.Name, xfrmrbp2, helpRibbonPage.ImageIndex);

            //Frm_BarButton_NhomKhach xfrmbrbt3 = new Frm_BarButton_NhomKhach();
            //TabCreating(xfrmrbp2.xtraTabControl1, iHelp.Name, iHelp.Name, xfrmbrbt3, 8);
        }

        private void iAbout_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_TienTe xfrmbrbt2 = new Frm_BarButton_TienTe();
            TabCreating(frmTienSanh.tabControl, iAbout.Name, iAbout.Name, xfrmbrbt2, 8);
    
        }

        private void tabMain_CloseButtonClick(object sender, EventArgs e)
        {
            DevExpress.XtraTab.XtraTabControl xtab = (DevExpress.XtraTab.XtraTabControl)sender;
            if (xtab.Name == "xtraTabPage1") return;
            if (xtab.SelectedTabPageIndex == 0) return;
            int i = xtab.SelectedTabPageIndex;
            xtab.TabPages.RemoveAt(xtab.SelectedTabPageIndex);
            xtab.SelectedTabPageIndex = i - 1;
        }

        private void btnKhachHang_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Name, rbPageDanhMuc.Name, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_BarButton_KhachHang xfrmbrbt8 = new Frm_BarButton_KhachHang();
            TabCreating(frmDanhMuc.tabControl, "Khách Hàng", btnKhachHang.Name, xfrmbrbt8, 8);
    
        }

        private void btnNhomKhach_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Name, rbPageDanhMuc.Name, frmDanhMuc, rbPageTienSanh.ImageIndex);
            Frm_BarButton_NhomKhach xfrmbrbt9 = new Frm_BarButton_NhomKhach();
            TabCreating(frmDanhMuc.tabControl, "Nhóm Khách", btnNhomKhach.Name, xfrmbrbt9, 8);
   
        }

        private void btnPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Name, rbPageDanhMuc.Name, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_Barbutton_Phong xfrmbrbt10 = new Frm_Barbutton_Phong();
            TabCreating(frmDanhMuc.tabControl, "Phòng", btnPhong.Name, xfrmbrbt10, 8);
   
        }

        private void btnLoaiPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Name, rbPageDanhMuc.Name, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_BarButton_LoaiPhong xfrmbrbt11 = new Frm_BarButton_LoaiPhong();
            TabCreating(frmDanhMuc.tabControl, "Loại Phòng", btnLoaiPhong.Name, xfrmbrbt11, 8);
   
        }        

        private void btnHHDV_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Text, rbPageDanhMuc.Text, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_BarButton_HangHoaDichVu xfrmbrbt13 = new Frm_BarButton_HangHoaDichVu();
            TabCreating(frmDanhMuc.tabControl, "HH-DV", btnHHDV.Name, xfrmbrbt13, 8);
   
        }

        private void btnNhomHHDV_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Text, rbPageDanhMuc.Text, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_BarButton_NhomHangHoaDichVu xfrmbrbt14 = new Frm_BarButton_NhomHangHoaDichVu();
            TabCreating(frmDanhMuc.tabControl, "N_HH-DV", btnNhomHHDV.Name, xfrmbrbt14, 8);
   
        }

        private void btnDatPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_RegistryRoom regis = new frm_RegistryRoom(null);
            regis.Show();
        }

        private void btnDSDatPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_DanhSachDatPhong xfrmbrbt15 = new Frm_BarButton_DanhSachDatPhong();
            TabCreating(frmTienSanh.tabControl, "DS Đặt Phòng", btnDSDatPhong.Name, xfrmbrbt15, 8);
      
        }

        private void btnSXDatPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Text, rbPageTienSanh.Text, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_SapXepPhongDatTruoc xfrmbrbt16 = new Frm_BarButton_SapXepPhongDatTruoc();
            TabCreating(frmTienSanh.tabControl, "Sắp Xếp Đặt Phòng", btnSXDatPhong.Name, xfrmbrbt16, 8);
     
        }

        private void btnDSNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_Barbutton_DanhSachNguoiDung frmlistuser = new Frm_Barbutton_DanhSachNguoiDung();
            TabCreating(frmTienSanh.tabControl, "DS Phòng Tài Khoản", btnDSPhongHuyDat.Name, frmlistuser, 8);

        }

        private void btnDSPhongHuyDat_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_DanhSachDatPhongBiHuy xfrmbrbt17 = new Frm_BarButton_DanhSachDatPhongBiHuy();
            TabCreating(frmTienSanh.tabControl, "DS Phòng Hũy Đặt", btnDSPhongHuyDat.Name, xfrmbrbt17, 8);
     
        }

        private void btnDKKhachLe_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_DKKhachLe dangky = new frm_DKKhachLe("");
            //dangky.FormClosed += new FormClosedEventHandler(dangky_FormClosed);
            dangky.ShowDialog();
            xfrmbrbt5.Frm_RoomDiagram_Load(null, null);
        }

        void dangky_FormClosed(object sender, FormClosedEventArgs e)
        {
            //var frm = sender as frm_DKKhachLe;
            //if (!string.IsNullOrEmpty(frm.MaPhong))
            //{
            //    var btn = CommonFunction.GetListRoomByText(this, "butRoom", frm.MaPhong, null) as Button;
            //    if (btn != null)
            //    {
            //        btn.BackColor = Color.Blue;
            //        btn.ForeColor = Color.Black;
            //    }
            //}
            //if (!string.IsNullOrEmpty(frm.MaPhongCu))
            //{
            //    var btn = CommonFunction.GetListRoomByText(this, "butRoom", frm.MaPhongCu, null) as Button;
            //    if (btn != null)
            //    {
            //        btn.BackColor = Color.Yellow;
            //        btn.ForeColor = Color.Black;
            //    }
            //}
        }

        private void btnSoDKKhachLe_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_SoDangKyKhachLe xfrmbrbt18 = new Frm_BarButton_SoDangKyKhachLe();
            TabCreating(frmTienSanh.tabControl, "Sổ đăng ký khách lẻ", btnSoDKKhachLe.Name, xfrmbrbt18, 8);
     
        }

        private void btnSoDKKhachDoan_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_SoDangKyKhachDoan xfrmbrbt19 = new Frm_BarButton_SoDangKyKhachDoan();
            TabCreating(frmTienSanh.tabControl, "Sổ đăng ký khách đoàn", btnSoDKKhachDoan.Name, xfrmbrbt19, 8);
     
        }

        private void btnSoHDTraPhong_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_SoHoaDonTraPhong xfrmbrbt21 = new Frm_BarButton_SoHoaDonTraPhong();
            TabCreating(frmTienSanh.tabControl, "Sổ hóa đơn trả phòng", btnSoHDTraPhong.Name, xfrmbrbt21, 8);
     
        }

        private void btnHDDV_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_HoaDonDichVu frmhoadon = new frm_HoaDonDichVu();
            frmhoadon.ShowDialog();
        }

        private void btnSoHDDV_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_SoHoaDonDichVu xfrmbrbt22 = new Frm_BarButton_SoHoaDonDichVu();
            TabCreating(frmTienSanh.tabControl, "Sổ hóa đơn dịch vụ", btnSoHDDV.Name, xfrmbrbt22, 8);
     
        }

        private void btnDSPhongCheckout_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageTienSanh.Name, rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);

            Frm_BarButton_DanhSachPhongCheckout xfrmbrbt23 = new Frm_BarButton_DanhSachPhongCheckout();
            TabCreating(frmTienSanh.tabControl, "Danh sách phòng Check-Out", btnDSPhongCheckout.Name, xfrmbrbt23, 8);
    
        }

        private void barButtonItem1_ItemClick_1(object sender, ItemClickEventArgs e)
        {

        }

        private void btnHome_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Name, rbPageDanhMuc.Name, frmDanhMuc, rbPageTienSanh.ImageIndex);

            Frm_RoomDiagram xfrmbrbt5 = new Frm_RoomDiagram();
            TabCreating(frmDanhMuc.tabControl, "Danh sách phòng", "DSPhong", xfrmbrbt5, 8);
        }

        private void btnDKKhachDoan_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_DKKhachDoan dangkynhom = new frm_DKKhachDoan();
            dangkynhom.ShowDialog();
            xfrmbrbt5.Frm_RoomDiagram_Load(null, null);
        }

        private void btnCheckoutphong_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_CheckOutMain frmcheckout = new frm_CheckOutMain();
            frmcheckout.ShowDialog();
            xfrmbrbt5.Frm_RoomDiagram_Load(null, null);
        }

        private void btnBaoCaoPhongCoKhach_ItemClick(object sender, ItemClickEventArgs e)
        {
            RP_DanhSachPhongDangCoKhach rplistphong = new RP_DanhSachPhongDangCoKhach();
            rplistphong.ShowPreview();
        }

        private void btnBackup_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_BackupDatabase frm = new frm_BackupDatabase();

            frm.ShowDialog();

        }

        private void btnRestore_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_RestoreDatabase frmres = new frm_RestoreDatabase();
            frmres.ShowDialog();
        }

        private void btnAuthor_ItemClick(object sender, ItemClickEventArgs e)
        {
            ThongTinTacGia thongtin = new ThongTinTacGia();
            thongtin.ShowDialog();
        }

        private void iSaveAs_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnThemNguoiDung_ItemClick(object sender, ItemClickEventArgs e)
        {
            frm_AddNewUser frmnewuser = new frm_AddNewUser();
            frmnewuser.ShowDialog();
        }
        
        private void btnDangNhap_ItemClick(object sender, ItemClickEventArgs e)
        {
           //Frm_Login frmlogin = new Frm_Login(2);
           ////this.Close();
           //frmlogin.ShowDialog();
        }

        private void btnDoiMatKhau_ItemClick(object sender, ItemClickEventArgs e)
        {

            frm_ChangePassword frmchangepass = new frm_ChangePassword(user);
            frmchangepass.ShowDialog();


        }

        private void btnQuocGia_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Text, rbPageDanhMuc.Text, frmDanhMuc, rbPageTienSanh.ImageIndex);
            Frm_BarButton_QuocGia xfrmbrbt5 = new Frm_BarButton_QuocGia();
            TabCreating(frmDanhMuc.tabControl, "Quốc gia", btnQuocGia.Name, xfrmbrbt5, 8);
        }

        private void btnThongKeLuotVaoRa_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnHelp_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnTienTe_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Text, rbPageDanhMuc.Text, frmDanhMuc, rbPageTienSanh.ImageIndex);
            Frm_BarButton_TienTe frm_TienTe = new Frm_BarButton_TienTe();
            TabCreating(frmDanhMuc.tabControl, "Tiền tệ", btnQuocGia.Name, frm_TienTe, 8);
        }

        private void Form1_FormClosed(object sender, FormClosedEventArgs e)
        {
            Application.Exit();
        }

        private void btnThongTinKho_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnCheckoutDoan_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnXemTienCoc_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnInHoaDon_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, "Tiền sảnh", rbPageTienSanh.Name, frmTienSanh, rbPageTienSanh.ImageIndex);
            frm_InHoaDon xfrmbrbt23 = new frm_InHoaDon();
            TabCreating(frmTienSanh.tabControl, "In hóa đơn trả phòng", btnInHoaDon.Name, xfrmbrbt23, 8);
        }

        private void btnHangTamUng_ItemClick(object sender, ItemClickEventArgs e)
        {

        }

        private void btnTamUng_ItemClick(object sender, ItemClickEventArgs e)
        {
            TabCreating(tabMain, rbPageDanhMuc.Text, rbPageDanhMuc.Text, frmDanhMuc, rbPageTienSanh.ImageIndex);

            frm_DanhSachTamUng frm = new frm_DanhSachTamUng();
            TabCreating(frmDanhMuc.tabControl, "Danh sách tạm ứng", btnTamUng.Name, frm, 8);
        }

    }
}